package org.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.annotation.JmsListener;

/**
 * 消费消息 模块
 */
@EnableJms //启用Jms
@SpringBootApplication
public class MqConsumApplication {

    public static void main(String[] args) {
        SpringApplication.run(MqConsumApplication.class);
    }


    //Queue 消息队列模式
    //消费1次
    //多个消费者依次按顺序消费 A、B、C...N

    //Topic 发布订阅模式
    //可以被多个消费者同时接收

    /**
     * 监听test_msg 消费消息
     *
     * @param msg 接收到的消息
     */
    @JmsListener(destination = "news_msg")
    public void consumTestMsg(String msg) {
        System.out.println("A接收到的消息:" + msg);
    }

    @JmsListener(destination = "news_msg")
    public void consumTestMsgB(String msg) {
        System.out.println("B接收到的消息:" + msg);
    }
}
